package core

import (
	"Blog/config"
	"Blog/global"
	"fmt"
	"gopkg.in/yaml.v2"
	"io/ioutil"
	"log"
)

// InitCoreConf 读取yaml文件配置
func InitCoreConf() {
	const ConfigFile = "settings.yaml"
	c := &config.Config{}
	yamlFile, err := ioutil.ReadFile(ConfigFile)
	if err != nil {
		panic(fmt.Errorf("get yaml err %s", err))
	}
	err = yaml.Unmarshal(yamlFile, c)
	if err != nil {
		log.Fatalf("Unmarshal yaml err %s", err)
	}
	log.Printf("config yamlfile load init success.")
	global.Config = c
}
